package main

import "fmt"

type Point struct{ X, Y float64 }

func (p Point) Add(q Point) Point {
	return Point{
		p.X + q.X,
		p.Y + q.Y,
	}
}

func (p Point) Sub(q Point) Point {
	return Point{
		p.X - q.X,
		p.Y - q.Y,
	}
}

type Path []Point

func (p Path) TranslateBy(offset Point, add bool) {
	var op func(q, p Point) Point
	if add {
		op = Point.Add
	} else {
		op = Point.Sub
	}

	for i, _ := range p {
		p[i] = op(p[i], offset)
	}

}
func main() {

	p := Path{
		Point{1, 2},
		Point{3, 4},
		Point{5, 6},
	}

	offset := Point{7, 8}

	p.TranslateBy(offset, true)

	fmt.Println(p)

}
